<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('订单管理')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
	<form id="form-order-add" class="form-horizontal">
		<h4 class="form-header h4">基本信息</h4>
		<div class="row">
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label"><span style="color: red; ">*</span>订单名称：</label>
					<div class="col-sm-8">
						<input id="orderName" placeholder="请输入订单名称" class="form-control" type="text" required>
					</div>
				</div>
			</div>
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label"><span style="color: red; ">*</span>订单编号：</label>
					<div class="col-sm-8">
						<input id="orderNumber" placeholder="请输入订单名编号" class="form-control" type="text" required>
					</div>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">订货时间：</label>
					<div class="col-sm-8">
						<input type="text" class="form-control time-input" data-type="datetime" id="orderTime" placeholder="请输入订货时间" />
					</div>
				</div>
			</div>
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">发货时间：</label>
					<div class="col-sm-8">
						<input type="text" class="form-control time-input" data-type="datetime" id="sendTime" placeholder="请输入发货时间" />
					</div>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">技术要求：</label>
					<div class="col-sm-8">
						<input id="skillRequire" placeholder="请输入技术要求" class="form-control" type="text">
					</div>
				</div>
			</div>
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">材质：</label>
					<div class="col-sm-8">
						<input id="material" placeholder="请输入材质" class="form-control" type="text">
					</div>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">尺寸：</label>
					<div class="col-sm-8">
						<input id="measure" placeholder="请输入尺寸" class="form-control" type="text">
					</div>
				</div>
			</div>
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">包装：</label>
					<div class="col-sm-8">
						<input id="pack" placeholder="请输入包装" class="form-control" type="text" required>
					</div>
				</div>
			</div>
		</div>
		<div class="row" style="display: none;">
			<input id="orderType" value="1">
			<input id="orderStatus" value="1">
			<input id="uniCode" value="">
			<input id="id" th:value="*{orderId}">
			<input id="subId" value="">
		</div>
		<h4 class="form-header h4">订单产品</h4>
		<div class="row">
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">10kv开关：</label>
					<div class="col-sm-8">
						<input id="switch10" placeholder="请输入数量" class="form-control" type="number">
					</div>
				</div>
			</div>
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">0.4kv开关：</label>
					<div class="col-sm-8">
						<input id="switch04" placeholder="请输入数量" class="form-control" type="number">
					</div>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">110kv开关：</label>
					<div class="col-sm-8">
						<input id="switch110" placeholder="请输入数量" class="form-control" type="number">
					</div>
				</div>
			</div>
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">35kv开关：</label>
					<div class="col-sm-8">
						<input id="switch35" placeholder="请输入数量" class="form-control" type="number">
					</div>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">10kv刀闸：</label>
					<div class="col-sm-8">
						<input id="gate10" placeholder="请输入数量" class="form-control" type="number">
					</div>
				</div>
			</div>
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">0.4kv刀闸：</label>
					<div class="col-sm-8">
						<input id="gate04" placeholder="请输入数量" class="form-control" type="number">
					</div>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">110kv刀闸：</label>
					<div class="col-sm-8">
						<input id="gate110" placeholder="请输入数量" class="form-control" type="number">
					</div>
				</div>
			</div>
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">35kv刀闸：</label>
					<div class="col-sm-8">
						<input id="gate35" placeholder="请输入数量" class="form-control" type="number">
					</div>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">地刀：</label>
					<div class="col-sm-8">
						<input id="ground" placeholder="请输入数量" class="form-control" type="number">
					</div>
				</div>
			</div>
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">手车双：</label>
					<div class="col-sm-8">
						<input id="doubleHandCar" placeholder="请输入数量" class="form-control" type="number">
					</div>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">手车单：</label>
					<div class="col-sm-8">
						<input id="signleHandCar" placeholder="请输入数量" class="form-control" type="number">
					</div>
				</div>
			</div>
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">电源12v1a：</label>
					<div class="col-sm-8">
						<input id="power121" placeholder="请输入数量" class="form-control" type="number">
					</div>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">电源12v2a：</label>
					<div class="col-sm-8">
						<input id="power122" placeholder="请输入数量" class="form-control" type="number">
					</div>
				</div>
			</div>
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">电源12v3a：</label>
					<div class="col-sm-8">
						<input id="power123" placeholder="请输入数量" class="form-control" type="number">
					</div>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">电源12v4a：</label>
					<div class="col-sm-8">
						<input id="power124" placeholder="请输入数量" class="form-control" type="number">
					</div>
				</div>
			</div>
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">电源12v5a：</label>
					<div class="col-sm-8">
						<input id="power125" placeholder="请输入数量" class="form-control" type="number">
					</div>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">电源12v10a：</label>
					<div class="col-sm-8">
						<input id="power1210" placeholder="请输入数量" class="form-control" type="number">
					</div>
				</div>
			</div>
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">电源12v29a：</label>
					<div class="col-sm-8">
						<input id="power1229" placeholder="请输入数量" class="form-control" type="number">
					</div>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">19位：</label>
					<div class="col-sm-8">
						<input id="byte19" placeholder="请输入数量" class="form-control" type="number">
					</div>
				</div>
			</div>
			<div class="col-sm-6">
				<div class="form-group">
					<label class="col-sm-4 control-label">29位：</label>
					<div class="col-sm-8">
						<input id="byte29" placeholder="请输入数量" class="form-control" type="number">
					</div>
				</div>
			</div>
		</div>
	</form>
</div>
<th:block th:include="include :: footer" />
<script>
	var prefix = ctx + "order";

	function submitHandler() {
		if ($.validate.form()) {
			var obj = JSON.stringify({
				orderTimeStr: $("#orderTime").val(),
				sendTimeStr: $("#sendTime").val(),
				order: {
					orderNumber: $("#orderNumber").val(),
					orderName: $("#orderName").val(),
					skillRequire: $("#skillRequire").val(),
					material: $("#material").val(),
					measure: $("#measure").val(),
					pack: $("#pack").val(),
					orderType: $("#orderType").val(),
					orderStatus: $("#orderStatus").val(),
					uniCode: $("#uniCode").val()
				},
				orderProduct: {
					id: $("#subId").val(),
					switch10: $("#switch10").val(),
					switch04: $("#switch04").val(),
					switch110: $("#switch110").val(),
					switch35: $("#switch35").val(),
					gate10: $("#gate10").val(),
					gate04: $("#gate04").val(),
					gate110: $("#gate110").val(),
					gate35: $("#gate35").val(),
					ground: $("#ground").val(),
					doubleHandCar: $("#doubleHandCar").val(),
					signleHandCar: $("#signleHandCar").val(),
					power121: $("#power121").val(),
					power122: $("#power122").val(),
					power123: $("#power123").val(),
					power124: $("#power124").val(),
					power125: $("#power125").val(),
					power1210: $("#power1210").val(),
					power1229: $("#power1229").val(),
					byte19: $("#byte19").val(),
					byte29: $("#byte29").val()
				}
			})
			var config = {
				url: prefix+'/'+$("#id").val(),
				type: "PUT",
				dataType: "json",
				contentType: 'application/json;charset=UTF-8',
				data: obj,
				beforeSend: function () {
					$.modal.loading("正在处理中，请稍后...");
				},
				success: function(result) {
					if(result.code == 0){
						$.operate.successCallback(result);
					}
				}
			};
			$.ajax(config)
		}
	}

	$(function() {
		var id = $("#id").val();
		var config = {
			url: prefix+'/'+id,
			type: "GET",
			dataType: "json",
			beforeSend: function () {
				$.modal.loading("正在处理中，请稍后...");
			},
			success: function(result) {
				if(result.code == 0){
					$("#orderTime").val(result.data.order.orderTime);
					$("#sendTime").val(result.data.order.sendTime);
					$("#orderNumber").val(result.data.order.orderNumber);
					$("#orderName").val(result.data.order.orderName);
					$("#skillRequire").val(result.data.order.skillRequire);
					$("#material").val(result.data.order.material);
					$("#measure").val(result.data.order.measure);
					$("#pack").val(result.data.order.pack);
					$("#orderType").val(result.data.order.orderType);
					$("#uniCode").val(result.data.order.uniCode);
					$("#subId").val(result.data.orderProduct.id);
					$("#switch10").val(result.data.orderProduct.switch10);
					$("#switch04").val(result.data.orderProduct.switch04);
					$("#switch110").val(result.data.orderProduct.switch110);
					$("#switch35").val(result.data.orderProduct.switch35);
					$("#gate10").val(result.data.orderProduct.gate10);
					$("#gate04").val(result.data.orderProduct.gate04);
					$("#gate110").val(result.data.orderProduct.gate110);
					$("#gate35").val(result.data.orderProduct.gate35);
					$("#ground").val(result.data.orderProduct.ground);
					$("#doubleHandCar").val(result.data.orderProduct.doubleHandCar);
					$("#signleHandCar").val(result.data.orderProduct.signleHandCar);
					$("#power121").val(result.data.orderProduct.power121);
					$("#power122").val(result.data.orderProduct.power122);
					$("#power123").val(result.data.orderProduct.power123);
					$("#power124").val(result.data.orderProduct.power124);
					$("#power125").val(result.data.orderProduct.power125);
					$("#power1210").val(result.data.orderProduct.power1210);
					$("#power1229").val(result.data.orderProduct.power1229);
					$("#byte19").val(result.data.orderProduct.byte19);
					$("#byte29").val(result.data.orderProduct.byte29);
					$.modal.closeLoading();
				}
			}
		};
		$.ajax(config)
	});

</script>
</body>
</html>
